package be;

import util.JSONObject;

/**
 *
 * @author Dikas
 */
public class Request {
    
    private String httpMethod;
    private String message;
    private String recurso;
    private String status;

    public Request() {
    }

    public String getHttpMethod() {
        return httpMethod;
    }

    public void setHttpMethod(String httpMethod) {
        this.httpMethod = httpMethod;
    }

    public String getMessaje() {
        return message;
    }

    public void setMessaje(String mensaje) {
        this.message = mensaje;
    }

    public String getRecurso() {
        return recurso;
    }

    public void setRecurso(String recurso) {
        this.recurso = recurso;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String toString() {
        return "Request{" + "httpMethod=" + httpMethod + ", message=" + message + ", recurso=" + recurso + ", status=" + status + '}';
    }
        
    public void toObject(String json)
    {
        try {
            JSONObject obj = new JSONObject(json);
            setHttpMethod(obj.getString("httpMethod"));
            setMessaje(obj.getString("message"));
            setRecurso(obj.getString("recurso"));
            setStatus(obj.getString("status"));            
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());     
            e.printStackTrace();
        }
    }
    
}
